/**   
 * @Title: ShiyixuanwuLossDataCommunicater.java 
 * @Package com.esun.rabbit2.communicaters.shiyixuanwu 
 * @Description: 十一选五漏号
 * @Author: Miko baoz@500wan.com   
 * @Date: 2011-6-30 下午07:03:10  
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.shiyixuanwu;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;

import com.esun.config.BussinessCode;
import com.esun.config.Key;
import com.esun.network.ServerCommunicater;
import com.esun.rabbit2.viewer.mainact.lotteryhallact.shiyixuanwu.rabbittrunk.ShiyixuanwuLossData;
import com.esun.util.log.EDebug;

/**
 * @ClassName: ShiyixuanwuLossDataCommunicater
 * @Description: 十一选五漏号交互类
 * @Author: Miko baoz@500wan.com
 * @Date: 2011-6-30 下午07:03:10
 * 
 */
public class ShiyixuanwuLossDataCommunicater extends ServerCommunicater {

	
	private static final String ROW_TAG_C0 = "c0";
	private static final String ROW_TAG_C = "c";

	private ArrayList<Hashtable<String, String>> alCache;

	public boolean getServerInfo() {

		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		HashMap<String, String> hm = new HashMap<String, String>();

		hm.put(BussinessCode.PASER_MID, BussinessCode.MID_SHIYIXUANWU_GETLOSSCODE);
		list.add(hm);

		try {
			super.getServerResponse(list, true);

			if (super.getState() == 100) {
				updateAlCach();
				return true;
			} else {
				return false;
			}
		} catch (Exception e) {
			return false;
		}
	}

	private void updateAlCach() {
		alCache = super.getListResult();
	}

	public Hashtable<String, String[]> getLossData() {

		Hashtable<String, String[]> htRet = new Hashtable<String, String[]>();

		for (int i = 0; i < alCache.size(); i++) {
			Hashtable<String, String> htTmpData = alCache.get(i);

			String[] str = new String[11];

			for (int j = 0; j < str.length; j++) {

				if (j < 9) {
					str[j] = htTmpData.get(ROW_TAG_C0 + (j + 1));
				} else if (j == 9) {
					str[j] = htTmpData.get(ROW_TAG_C + (j + 1));
				} else {
					str[j] = htTmpData.get(ROW_TAG_C + (j + 1));
				}
			}

			EDebug.o(this, str);

			int flag = Integer.parseInt(htTmpData.get(Key.KEY_FLAG));

			if (flag == 1) {

				ShiyixuanwuLossData.getLossData().setSpace1(str);

			} else if (flag == 2) {

				ShiyixuanwuLossData.getLossData().setSpace2(str);

			} else if (flag == 3) {

				ShiyixuanwuLossData.getLossData().setSpace3(str);

			} else if (flag == 4) {

				ShiyixuanwuLossData.getLossData().setFree(str);

			} else if (flag == 6) {

				ShiyixuanwuLossData.getLossData().setZu2(str);

			} else if (flag == 7) {

				ShiyixuanwuLossData.getLossData().setZu3(str);

			}
		}
		return htRet;
	}
}
